// 购物车相关的操作接口
import service from "./index";
const prefix = "/cart";

// 新增购物车信息
export function addCart(cart) {
  return service({
    url: `${prefix}/addCart`,
    method: "POST",
    data: cart,
  });
}

// 查询所有购物车信息
export function list() {
  return service({
    url: `${prefix}/list`,
    method: "GET",
  });
}

// 删除购物车信息
export function deleteById(id) {
  return service({
    url: `${prefix}/delete/${id}`,
    method: "DELETE",
  });
}

// 清空购物车信息
export function deleteAll() {
  return service({
    url: `${prefix}/deleteAll`,
    method: "DELETE",
  });
}

// 分页查询购物车信息
export function pageList(pageInfo) {
  return service({
    url: `${prefix}/pageList`,
    method: "GET",
    params: pageInfo,
  });
}

// 查询总钱
export function getTotalMoney() {
  return service({
    url: `${prefix}/getTotalMoney`,
    method: "GET",
  });
}

// 根据购物车id修改数量
export function updateGoodsSum(carId, goodsSum) {
  return service({
    url: `${prefix}/updateGoodsSum`,
    method: "PUT",
    data: {
      id: carId,
      goodsSum: goodsSum,
    },
  });
}
